package cn.hxzy.controller;


import cn.hxzy.common.Result;
import cn.hxzy.common.util.RandomId;
import cn.hxzy.config.redisConfig.RedisConfig;
import cn.hxzy.entity.order.AbnormalReporting;
import cn.hxzy.service.AbnormalReportingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;
import java.util.Date;
import java.util.UUID;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hk
 * @since 2023-06-23
 */
@CrossOrigin
@RestController
@RequestMapping("/abnormalReporting")
public class AbnormalReportingController {
    @Autowired
    private AbnormalReportingService abnormalReportingService;
    @Autowired
    private RedisConfig redisConfig;
    @PostMapping("/abnormals")
    public Result insertabnormalReporting(@RequestBody AbnormalReporting abnormalReporting){


        abnormalReporting.setExceptionId(RandomId.getYcId());
        abnormalReporting.setExceptionType(105);
        abnormalReporting.setCreateTime(new Date());
        boolean save = abnormalReportingService.save(abnormalReporting);
        if (save) return Result.ok().message("上传成功！").data1(abnormalReporting.getExceptionId());
        return Result.error().message("上传失败！");
    }




}

